package com.zxw.java基础.socket.BIO;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 * @projectName: util-cloud
 * @package: com.zxw.java基础.scolet
 * @className: Client
 * @author: zhangxuewei
 * @description: TODO
 * @date: 2023/11/4 15:49
 * @version: 1.0
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = null;
        ObjectOutputStream output = null;
        ObjectInputStream input = null;
        InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 10002);

        try {
            socket = new Socket();
            socket.connect(addr);
            output = new ObjectOutputStream(socket.getOutputStream());
            input = new ObjectInputStream(socket.getInputStream());
            output.writeUTF("zxw mmm zjl");
            output.flush();
            System.out.println(input.readUTF());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (null != socket) socket.close();
            if (null != output) output.close();
            if (null != input) input.close();
        }
    }

}
